home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7051 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: gail.ripco.com!mambuhl
  2. From: mambuhl@ripco.com (Martin Ambuhl)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: string and NULL :ques
  5. Date: 17 Feb 1996 21:00:31 GMT
  6. Organization: Ripco Communications, Inc.
  7. Message-ID: <4g5flf$bil@gail.ripco.com>
  8. NNTP-Posting-Host: foley.ripco.com
  9.  
  10. zakrzews@pegasus.montclair.edu (Tomas Zakrzewski)
  11. in <zakrzews.824018783@pegasus.montclair.edu> asks:
  12.  
  13. >Is it save to use a string library and stdio library with strings that are
  14. >no terminated by NULL charater. If is not, which function may not work correctl
  15. >and what would happen with non termianded string if a function is applied to
  16. >that string.
  17.  
  18. From the standard (ISO 7.1.1):
  19. "A string is a contiguous sequence of characters terminated by and
  20. including the first null character."
  21.  
  22. So your question makes no sense:  there is no such thing as a string not
  23. terminated by a null character.  And it is `null'; `NULL' is a null
  24. pointer, not a null character.
  25.  
  26. If you want to work on a char array which does not contain a null
  27. character, how do you propose to tell the library functions where it
  28. ends?
  29.  
  30. One possible result of using the library functions on such a char array
  31. is a segfault.  On M$BrokenOS, the results are completely unpredictable,
  32. since there is no protection against access (including writing) of
  33. regions containing other data, your program, or even portions of the OS.
  34.                                                                
  35. --
  36. * Martin Ambuhl       net: mambuhl@ripco.com
  37. * Chicago, IL (USA)    
  38.